package cn.tedu.csmall.cart.webapi.mapper;

import cn.tedu.csmall.commons.pojo.cart.entity.Cart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface CartMapper {

    //向购物车中添加商品信息
    @Insert("INSERT INTO cart_tbl(commodity_code,price,count,user_id) " +
            "VALUES(#{commodityCode},#{price},#{count},#{userId})")
    int insertCart(Cart cart);

    //根据用户id和商品id删除购物车表中的信息
    @Delete("DELETE FROM cart_tbl WHERE user_id = #{userId} AND commodity_code = #{commodityCode}")
    int deleteCartByUserIdAndCommodityCode(@Param("userId") String userId,@Param("commodityCode") String commodityCode);

}
